package cn.rui.utils;

import cn.hutool.http.HttpUtil;
import cn.rui.pojo.vo.CityInfo;
import net.sf.json.JSONObject;

/**
 * 查询所在地信息
 *
 * @author 徽州大都督
 * @date 2021/05/18
 */
public class QueryCityInfoUtils {


    public static CityInfo queryCity(String ip) {

            String ss = HttpUtil.get ("https://apis.map.qq.com/ws/location/v1/ip?ip="+ ip +"&key=GHXBZ-P5UHX-MIL44-ZTS22-T7CNQ-GHBT4");

            JSONObject jsonObject = JSONObject.fromObject (ss);
            CityInfo cityInfo = (CityInfo) JSONObject.toBean (jsonObject, CityInfo.class);

            return cityInfo;
    }
}
